unit dcudeps;

interface

uses
  Windows,
  Classes;

function GetDeps(const Name: string; sources, deps: TStrings): BOOL;

implementation

uses
  SysUtils,
  DCU32;

type
  TUnit = class(DCU32.TUnit)
  end;

function GetDeps(const Name: string; sources, deps: TStrings): BOOL;
var
  i: integer;
  U: TUnit;
  SFR: PSrcFileRec;
  URec: PUnitImpRec;
begin
  Result := False;
  sources.Clear;
  deps.Clear;
  U := TUnit.Create;
  try
    if not U.Load(Name, 0, False, nil) then
      Exit;
    SFR := U.FSrcFiles;
    while SFR <> nil do
    begin
      //if SFR^.Def^.Tag=drSrc then
        sources.Add(SFR^.Def^.Name);
      SFR := SFR^.Next;
    end;
    for i := 0 to U.FUnitImp.Count - 1 do
    begin
      URec := U.UnitImpRec[i];
      if URec <> nil then
        deps.Add(URec^.Name^);
    end;
    Result := True;
  finally
    U.Free;
  end;
end;

end.